<template>
	<view>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30">
			<view class="u-m-r-10">
				<!-- <u-avatar :src="vuex_user.avatar_url" size="140"></u-avatar> -->
				<view>
					<oss-upload></oss-upload>
				</view>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{vuex_user.name ? vuex_user.name : '姓名'}}</view>
				<view class="u-font-14 u-tips-color">邮箱: {{vuex_user.email ? vuex_user.email : '邮箱'}}</view>
			</view>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="account" title="个人信息" @click="toRoute('pages/center/baseInfo')"></u-cell-item>
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="order" title="所有订单" @click="toRoute('pages/center/all-cart')"></u-cell-item>
				<u-cell-item icon="shopping-cart" title="商品收藏"></u-cell-item>
				<u-cell-item icon="map" title="收获地址"></u-cell-item>
			</u-cell-group>
		</view>
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="reload" title="退出登录" @click="loginOut"></u-cell-item>
			</u-cell-group>
		</view>

	</view>
</template>

<script>
	import ossUpload from '../../components/oss-upload/oss-upload.vue'
	export default {
		components:{
			ossUpload
		},
		data() {
			return {
				pic: 'https://uviewui.com/common/logo.png',
				show: true
			}
		},
		onLoad() {
			// console.log(this.vuex_user)
			let flag = this.$u.utils.isLogin();
			if (!flag) return;
		},
		methods: {
			// 路由跳转
			toRoute(url, type = 'to') {
				this.$u.route({
					url,
					type
				})
			},
			// 退出登录
			async loginOut() {
				await this.$u.api.loginOut();
				this.$u.vuex('vuex_token', null);
				this.$u.vuex('vuex_user', {});
				this.$u.toast('退出成功');
				setTimeout(() => {
					this.$u.route({
						type: 'reLaunch',
						url: 'pages/index/index'
					})
				}, 1500)
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #ededed;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}
</style>
